package com.magic.gre.mvp.presenter;

import android.renderscript.BaseObj;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.WordsDetailsBean;
import com.magic.gre.entity.base.BaseObjectModel;
import com.magic.gre.mvp.contract.WordsDetailsContract2;
import com.magic.gre.mvp.model.WordsDetailsModelImpl2;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

/**
 * Author: Lmoumou
 * Date: 2019-01-28 10:35
 * 文件名: WordsDetailsPresenterImpl2
 * 描述:
 */
public class WordsDetailsPresenterImpl2 extends BasePresenterImpl<WordsDetailsContract2.View, WordsDetailsContract2.Model>
        implements WordsDetailsContract2.Presenter {
    public WordsDetailsPresenterImpl2(WordsDetailsContract2.View view) {
        super(view);
    }

    @Override
    protected WordsDetailsContract2.Model creatModel() {
        return new WordsDetailsModelImpl2();
    }

    @Override
    public void pWordsDetails(String id) {
        mModel.mWordsDetails(new CommonObserver<BaseObjectModel<WordsDetailsBean>>(new TypeToken<BaseObjectModel<WordsDetailsBean>>(){}.getType()) {
            @Override
            protected void onSuccess(BaseObjectModel<WordsDetailsBean> wordsDetailsBeanBaseObjectModel) {
                mView.vWordetails(wordsDetailsBeanBaseObjectModel.body);
            }

            @Override
            public void onError(int status, String msg) {
                mView.doPrompt(msg);
            }
        }, id);
    }
}
